#ifndef SERIALIZATION_HELPER_H
#define SERIALIZATION_HELPER_H

#include <QtCore/QVariant>

namespace core
{
class ISerializable;

class SerializationEngine
{
public:
    virtual QString serialize(const ISerializable* obj,
        bool* serializedProperly) const;
    virtual bool deserialize(const QString& serialized, ISerializable* obj) const;

protected:
    QString serializeString(const QString& property,
        const QVariantList& string, bool& proper) const;
    QString serializeInt(const QString& property,
        const QVariantList& integer, bool& proper) const;
    QString serializeUInt(const QString& property,
        const QVariantList& integer, bool& proper) const;
    QString serializeReal(const QString& property,
        const QVariantList& real, bool& proper) const;
    QString serializePoint(const QString& property,
        const QVariantList& point, bool& proper) const;
    QString serializeListOfPoints(const QString& property,
        const QVariantList& points, bool& proper) const;
    QString serializeColor(const QString& property,
        const QVariantList& color, bool& proper) const;

    QVariantList deserializeString(const QString& serialized,
        bool& proper) const;
    QVariantList deserializeInt(const QString& serialized,
        bool& proper) const;
    QVariantList deserializeUInt(const QString& serialized,
        bool& proper) const;
    QVariantList deserializeReal(const QString& serialized,
        bool& proper) const;
    QVariantList deserializePoint(const QString& serialized,
        bool& proper) const;
    QVariantList deserializeListOfPoints(const QString& serialized,
        bool& proper) const;
    QVariantList deserializeColor(const QString& serialized,
        bool& proper) const;

private:
    QPointF deserializePointHelper(const QString &serialized,
        bool &proper) const;
    QStringList split(const QString& serialized, const QChar& separator,
        const QChar& leftLeveler, const QChar& rightLeveler) const;
};

} // namespace core

#endif
